<?php
include_once('config/_conf.php');
include_once('config/twitterAPI.php');

$accesskey = $_GET['ak'];
$tweet = $_POST['tweet'];

if($accesskey == $config['accesskey']){
	if($tweet == '') {
		include_once('form.php');
	} else {
		if(strlen($tweet) <= 140) {
		postToTwitter($config['username'], $config['password'], $tweet);
		} else {
			$earlyvalue = $tweet;
			$message = "Sorry, more than 140 characters doesn't work";
			
			include_once('form.php');
		}
	}
} elseif($accesskey == '') {
	die('You need the access key to proceed.');
} else {
	die('Wrong access key or other error.');
}
?>